import sys
import pika

mq_host = '192.168.19.117'
mq_vhost = 'ceshi_vhost'
mq_queue_name = 'xxsszf'
mq_username = 'ceshi'
mq_password = 'ceshi'

str1='25666932129@chatroom|下午下班前提醒,---------------请同志们查收(*^__^*) 嘻嘻……'
print(str1.find('|'))
print(str1[0:str1.find('|')])
print(str1[str1.find('|')+1:])
def main():
    credentials = pika.PlainCredentials(mq_username, mq_password)
    connection = pika.BlockingConnection(
        pika.ConnectionParameters(host=mq_host, port=5672, credentials=credentials,virtual_host=mq_vhost)
    )
    channel = connection.channel()

    # 创建一个hello的对列
    channel.queue_declare(queue=mq_queue_name,durable=True)

    # 回调函数，队列中有消息就会触发
    def callback(ch, method, properties, body):
        print("来自队列：%r" % str(body, encoding='utf8'))

    channel.basic_consume(queue=mq_queue_name, on_message_callback=callback, auto_ack=True)
    print('等待中...')
    channel.start_consuming()

main()